/**
 * @file do_try.cpp
 *
 * A temporary file for playing with stuff
 *
 * @author Dahua Lin
 */

#include <cstdio>
#include <functional>

#include <slipp/base/timer.h>
#include <slipp/prob_base/rstream.h>
#include <slipp/prob_base/uniform_distr.h>

#include <slipp/eigen_ex/eigen_efuns.h>


// using namespace Eigen;

using namespace sli;

void try1()
{
	using Eigen::ArrayXd;

	ArrayXd a(4);
	a << 1.2, 2.3, 3.4, 4.5;

	for (int i = 0; i < a.size(); ++i)
	{
		std::printf("%g ", a(i));
	}
	std::printf("\n");

	ArrayXd b = vpow(a, a);

	for (int i = 0; i < b.size(); ++i)
	{
		std::printf("%g ", b(i));
	}

	std::printf("\n");
}


void try2()
{
	typedef std_rstream<std::mt19937_64> rstream_t;
	rstream_t rstr;

	size_t N = 1000000;
	uint32_t *u = new uint32_t[N];
	double *a = new double[N];
	int nrepeats = 10;

	sli::timer tm(true);
	for (int i = 0; i < nrepeats; ++i)
	{
		for (size_t j = 0; j < N; ++j)
		{
			a[i] = rstr.rand_f64();
		}
	}
	std::printf("randf64: speed = %.3f mps\n", double(nrepeats) / tm.elapsed(SECONDS));

	tm.start();
	for (int i = 0; i < nrepeats; ++i)
	{
		for (size_t j = 0; j < N; ++j)
		{
			u[i] = rstr.rand_u32();
		}
	}
	std::printf("randu32: speed = %.3f mps\n", double(nrepeats) / tm.elapsed(SECONDS));

	delete[] a;
}


int main(int, char **)
{
	try2();

	return 0;
}


